package com.demo.afternoon;

import java.io.*;

/**
 * @ClassName FileTest
 * @Description TODO
 * @Author tianqinglong
 * @Date 14:31 2022/7/7
 * @Version 1.0
 **/
public class FileTest {
    public static void main(String[] args) throws IOException {
        File a = new File("D:\\tql\\gitstudy\\day04\\src\\com\\demo\\afternoon", "a.txt");
//        a.createNewFile();

        File file = new File("src\\com\\demo\\afternoon\\a.txt");
//        System.out.println(file.getName());//a.txt
//        System.out.println(file.getPath()); //src\com\demo\afternoon\a.txt
//        System.out.println(file.length());//0
//        System.out.println(a.getAbsoluteFile());//D:\tql\gitstudy\src\com\demo\afternoon\a.txt

        FileReader is = new FileReader("D:\\tql\\gitstudy\\day04\\src\\com\\demo\\afternoon\\a.txt");
        Reader reader = new InputStreamReader(new FileInputStream("D:\\tql\\gitstudy\\day04\\src\\com\\demo\\afternoon\\a.txt"), "UTF-8");
        char[] data = new char[1024];
        int len = -1;
        while ((len = reader.read(data)) != -1) {
            System.out.println(new String(data, 0, len));
        }
        reader.close();
        is.close();

        OutputStream output = new FileOutputStream("D:\\tql\\gitstudy\\day04\\src\\com\\demo\\afternoon\\a.txt",true);
     /* output.write(97);//a
        output.write(98);//b
        output.write(99);//c  */

        String str="我想测试一下数据能不能写进去";
        byte[] data1=str.getBytes();
//        output.write("\r\n".getBytes());
//        output.write(data1);
        output.close();
    }
}
